﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

using System.IO;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using GeneralDefine;
using GeneralLib;
using System.ComponentModel;

namespace IOModule
{
    [XmlInclude(typeof(IOOutputItem))]
    public class IOOutputItem
    {
        public string strName;
        public int iChannal;
        public string strRemark;
        [XmlIgnore]
        private IOutput actioner;
        public IOOutputItem()
        {
            strName = "";
            strRemark = "";
            iChannal = 0;
        }
        public void RefreshActioner()
        {
            
              actioner = (IOutput)FrameManager.FrameManager.MotionCard;
            
        }
        [XmlIgnore, Browsable(false)]
        public bool ON
        {
            get
            {
                bool bResult = false;
                if (actioner == null)
                {
                    return false;
                }
                else
                {
                    bResult = actioner.GetOutBit(iChannal);
                }
                return bResult;
            }
            set
            {
                if (value == true)
                {
                    if (actioner != null)
                    {
                        actioner.SetOutBit(iChannal, true);
                    }
                }
                else
                {
                    if (actioner != null)
                    {
                        actioner.SetOutBit(iChannal, false);
                    }
                }
            }
        }
        [XmlIgnore, Browsable(false)]
        public bool OFF
        {
            get
            {
                bool bResult = false;
                if (actioner == null)
                {
                    return true;
                }
                else
                {
                    bResult = !actioner.GetOutBit(iChannal);
                }
                return bResult;
            }
            set
            {
                if (value == true)
                {
                    if (actioner != null)
                    {
                        actioner.SetOutBit(iChannal, false);
                    }
                }
                else
                {
                    if (actioner != null)
                    {
                        actioner.SetOutBit(iChannal, true);
                    }
                }
            }
        }
        public string Name
        {
            get { return strName; }
            set { strName = value; }
        }
        public int Channal
        {
            get { return iChannal; }
            set { iChannal = value; }
        }
       
        public string Remark
        {
            get { return strRemark; }
            set { strRemark = value; }
        }

    }
}
